


package com.UMLife.me.action;

import com.UMLife.me.global.Global;
import com.UMLife.me.ui.MainMenu;
import de.enough.polish.ui.ChoiceGroup;
import de.enough.polish.ui.Command;
import de.enough.polish.ui.CommandListener;
import de.enough.polish.ui.Displayable;
import de.enough.polish.ui.Item;
import de.enough.polish.ui.ItemStateListener;





public class MainMenuAction implements ItemStateListener, CommandListener
{
	public MainMenuAction(MainMenu mainMenu, ChoiceGroup choice)
	{
		this.mainMenu = mainMenu;
		this.choice = choice;
		this.cmdExit = Global.getCmdExit();
		this.mainMenu.addCommand(this.cmdExit);
	}
	
	public void commandAction(Command c, Displayable d)
	{
		if (c == this.cmdExit)
		{
			Global.getGlobalMIDlet().notifyDestroyed();
		}
		
	}
	
	public void itemStateChanged(Item i)
	{
		if (i == this.choice)
		{
			int index = this.mainMenu.getSelected();
			if (index == 0)//马上答题
			{
				Global.getGlobalDisplay().setCurrent(Global.getQuestionUI());
			}
			if (index == 1)//幸运榜
			{
				Global.getGlobalDisplay().setCurrent(Global.getRankUI());
			}
			if (index == 2)//成绩单
			{
				Global.getGlobalDisplay().setCurrent(Global.getAboutMeUI());
			}
			if (index == 3)//帮助
			{
				Global.getGlobalDisplay().setCurrent(Global.getAboutItUI());
			}
			if (index == 4)//关于我们
			{
				Global.getGlobalDisplay().setCurrent(Global.getAboutUsUI());
			}
			
		}
		
	}
	
	private ChoiceGroup	choice;
	
	private Command		cmdExit;
	
	private MainMenu	mainMenu;
	
}
